package com.wt.chat.response;

import com.fasterxml.jackson.annotation.JsonInclude;

import java.util.HashMap;
import java.util.Map;

/**
 * @description
 * @author: wangtao
 * @date:15:00 2019/11/8
 * @email:taow02@jumei.com
 */
@JsonInclude(JsonInclude.Include.NON_NULL)
public class ResponseResult {

	private Integer code;
	private String msg;
	private Map<String, Object> resultBody;

	public ResponseResult code(Integer code) {
		this.code = code;
		return this;
	}

	public ResponseResult msg(String msg) {
		this.msg = msg;
		return this;
	}

	public ResponseResult body(Object body) {
		this.properties("body", body);
		return this;
	}

	public ResponseResult properties(String key, Object body) {
		if (resultBody == null) {
			resultBody = new HashMap<>();
		}
		this.resultBody.put(key, body);
		return this;
	}

	public Integer getCode() {
		return code;
	}

	public String getMsg() {
		return msg;
	}

	public Map<String, Object> getResultBody() {
		return resultBody;
	}

	public enum CodeType {
		/**
		 * 正常
		 */
		OK(0, "正常"),
		/**
		 * 异常
		 */
		ERROR(1, "异常");
		private Integer value;
		private String desc;

		CodeType(int value, String desc) {
			this.value = value;
			this.desc = desc;
		}

		public Integer getValue() {
			return value;
		}
	}
}
